﻿package com.winmastergames.lolgame {
	import flash.display.MovieClip;
	import flash.display.Stage;
	import flash.geom.ColorTransform;

	/*
	   Advanced Flash Engine in ActionScript 3.
	   Copyright (C) 2009  Dean Gardiner, Taylor Lodge

	   This program is free software: you can redistribute it and/or modify
	   it under the terms of the GNU General Public License as published by
	   the Free Software Foundation, either version 3 of the License, or
	   (at your option) any later version.

	   This program is distributed in the hope that it will be useful,
	   but WITHOUT ANY WARRANTY; without even the implied warranty of
	   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	   GNU General Public License for more details.

	   You should have received a copy of the GNU General Public License
	   along with this program.  If not, see <http://www.gnu.org/licenses/>.
	 */
	public class barrier extends MovieClip {
		public var b_x:int;
		public var b_y:int;
		public var b_width:int;
		public var b_height:int;
		public var b_index:int;
		public var b_damageLevel:Number;

		public function barrier(stage:MovieClip, bX:int, bY:int, bW:int, bH:int, bDL:int){
			stage.addChild(this);
			width = bW;
			height = bH;
			b_damageLevel = bDL;
			b_x = bX;
			b_y = bY;
			b_width = bW;
			b_height = bH;
			x = b_x;
			y = b_y;
			var colorTransform:ColorTransform = this.transform.colorTransform;
			colorTransform.color = 0x33FF00;
			this.transform.colorTransform = colorTransform;
		}

		public function damageBarrier(damageRate:Number){
			b_damageLevel += damageRate;
			//Set Colour
			var colorTransform:ColorTransform = this.transform.colorTransform;
			switch(Math.round(b_damageLevel))
			{
				case 9:
					//Red
					colorTransform.color = 0xFF0000;
					break;
				case 6:
					//Orange
					colorTransform.color = 0xFF9933;
					break;
				case 3:
					//Dark Green
					colorTransform.color = 0x003300;
					break;
				case 0:
					//Green
					colorTransform.color = 0x33FF00;
					break;
			}
			this.transform.colorTransform = colorTransform;
		}

		public function repairBarrier(repairRate:int){
			b_damageLevel += repairRate;
		}
	}
}